/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Types for a ObjectDB interface.
 * \author Antti Maula <antti.maula@tkk.fi>
 *
 * $Id: ObjectDBTypes.hpp,v 1.3 2009-09-01 12:56:27 amaula Exp $
 *
 */
#ifndef _MACI_OBJECTDBTYPES_HPP_
#define _MACI_OBJECTDBTYPES_HPP_
#include <inttypes.h>
#include "ownutils.h"
#include "owndebug.h"
#include "common/text.hpp"

namespace MaCI {

  /** MaCI - ObjectDB interface.
   *
   * This namespace contains all the methods and types related
   * to the ObjectDB interface.
   *
   * \note This interface is still under heavy developement. Please
   * consider this interface to be on Alpha stage of testing before
   * this note is removed!
   */
  namespace ObjectDB {
    
    /** Enumeration types for ObjectDB data elements.
     */
    enum EObjectDBType { 
      KTypeUnknown               = -1, ///< Unkown type.
      KTypeTimestamp             = 1,  ///< Common::TTimestamp element.
      KTypeCommand               = 2,  ///< TCommand element.
      KTypeDBObjectHandleSingle  = 3,  ///< TDBObjectHandle element.
      KTypeDBObjectName          = 4,  ///< TDBObjectName element.
      KTypeDBObjectType          = 5,  ///< TDBObjectType element.
      KTypeDBObjectDescription   = 6,  ///< TDBObjectDescription element.
      KTypeDBObjectHandleArray   = 7,  ///< TDBObjectHandleArray element.

      KTypeDBObjectPose          = 8,  ///< TDBObjectPose element.
      KTypeDBObjectBoundingBox   = 9   ///< TDBObjectBoundingBox element.
    };
    
    
    /** Enumerations for ObjectDB Command.
     */
    enum EObjectDBCommand { 
      /** Generate new RealObject. 
       *
       * \li Command: No parameters
       * \li Reply: data contains ID of new element or zero on error.
       */
       KCommandGenerateRealObject         = 1,

      /// Get RealObject information. ObjectHandle stored in 'data',
      /// or zero when multiple elements follow in
      /// KTypeDBObjectHandleArray type.
      KCommandGetRealObjectInformation   = 2,

      KCommandSetRealObjectInformation   = 3,

      /// Get RealObject Pose. ObjectHandle stored in 'data'.
      KCommandGetRealObjectPose          = 4,

      KCommandSetRealObjectPose          = 5,

      KCommandGetRealObjectBoundingBox   = 6,

      KCommandSetRealObjectBoundingBox   = 7,

      KCommandGetRealObjectsBySelection  = 8     
    };


    /** Enumerations for ObjectDB flags.
     */
    enum EObjectDBFlags {
      KFlagReply                         = (1<<0),
      KFlagFooAndBaar                    = (1<<1)
    };


    /** ObjectDB command.
     *
     * This structure contains command field to be used when sending
     * action requests to ObjectDB enabled clients.
     *
     * \see EObjectDBCommand
     */
    struct TCommand 
    {
      TCommand(const unsigned int aCmd = 0,
               const unsigned int aFlags = 0)
	: cmd(aCmd),
          flags(aFlags) {}
      uint16_t cmd;             ///< Command. See EObjectDBCommand.
      uint16_t flags;           ///< Command flags. See EObjectDBFlags;
    };

    
    /** Single handle.
     *
     */
    struct TDBObjectHandleSingle
    {
      TDBObjectHandleSingle(const uint32_t aHandle) 
        : handle(aHandle) {}
      uint32_t handle;
    };
    

    /** Array of handles. 
     * 
     */
    struct TDBObjectHandleArray
    {
      TDBObjectHandleArray(const uint32_t aCount)
        : handlecount(aCount),
          handlearray() {}
      uint32_t handlecount;
      uint32_t handlearray[];
    };

    typedef Common::TText TDBObjectName;


    typedef Common::TText TDBObjectType;


    typedef Common::TText TDBObjectDescription;
    
  }
}

#endif
